package com.woniuxy.controller;

import com.woniuxy.entity.WeatherDTO;
import com.woniuxy.service.WeatherService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/medical")
@RequiredArgsConstructor
public class WeatherController {
    private final WeatherService weatherService;

    @GetMapping("/date")  //   /medical/date
    public ResponseEntity<WeatherDTO> getWeatherByDate(
            @RequestParam("date")  String date // 接收前端传来的日期参数
    ) {

        WeatherDTO weather = weatherService.getDateWeather(date);
        return ResponseEntity.ok(weather);
    }
}